#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <sys/wait.h>
#include <sys/syscall.h>

int main()
{
    pid_t k;
    int ret;
    k = fork();
    if (k < 0)
    {
        perror("fork error!\n");
        exit(-1);
    }
    else if (k == 0)
    {
        printf("parent pid=%d,child pid=%d\n", getppid(), getpid());
        raise(SIGSTOP);
        exit(0);
    }
    else
    {
        sleep(2);
        printf("child pid=%d\n", k);
        if (waitpid(k, NULL, WNOHANG) == 0)
        {
            ret = kill(k, 9);
            if (ret == 0)
            {
                printf("return value of kill: %d\n", ret);
            }
            else
            {
                printf("kill failed!\n");
            }
        }
    }
}